package com.xiaobias.a06;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;

public class MyBean implements BeanNameAware, ApplicationContextAware, InitializingBean {

     private static final Logger logger = LoggerFactory.getLogger(MyBean.class);

    @Override
    public void setBeanName(String name) {
        logger.debug("当前bean " + this + " 名字叫：" + name);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        logger.debug("当前bean " + this + " 容器是：" + applicationContext);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        logger.debug("当前bean " + this + " 初始化");
    }

    @Autowired
    public void aaa(ApplicationContext applicationContext) {
        logger.debug("当前bean " + this + " 使用@Autowired容器是：" + applicationContext);
    }
    @PostConstruct
    public void inti() {
        logger.debug("当前bean " + this + " 使用@PostConstruct初始化");
    }

}
